package com.test.demo;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

/**
 * ${DESCRIPTION}
 *
 * @author muxiaoyu
 * @create 2017/05/15 14:57
 **/
public class InfoImpl implements Info<String> {
    private String t;

    @Override
    public String getInfo() {
        return t;
    }

    public InfoImpl(String t) {
        this.t = t;
    }

    public InfoImpl() {
        Class clazz = this.getClass();
        ParameterizedType type = (ParameterizedType) clazz.getGenericSuperclass();
        Type[] actualTypeArguments = type.getActualTypeArguments();
        System.out.println(actualTypeArguments[0]);
    }

    @Override
    public String toString() {
        return "InfoImpl{" +
                "t=" + t +
                '}';
    }

    public static void main(String[] args) {
        Info<String> info = new InfoImpl();
        System.out.println(InfoImpl.name);
        System.out.println(info);
        // List<String> list = new ArrayList<String>();
    }
}
